package com.magenta.maxoptra.gis.commons;

import java.io.Serializable;

/**
 * User: KuznetsovD
 * Date: 25.06.2009
 * Time: 16:04:57
 */
public class Pair<First, Second> implements Serializable {
    private final First first;
    private final Second second;

    public Pair(First first, Second second) {
        this.first = first;
        this.second = second;
    }

    public First getFirst() {
        return first;
    }

    public Second getSecond() {
        return second;
    }

    public boolean equals(Object o) {
        return first.equals(((Pair) o).getFirst()) && second.equals(((Pair) o).getSecond());
    }

    public int hashCode() {
        return first.hashCode() + second.hashCode();
    }

    @Override
    public String toString() {
        return "{" +
                first +
                ", " + second +
                '}';
    }

    public Object[] toArray() {
    	return new Object[] { first, second };
    }

    public static <First, Second> Pair<First, Second> generate(First f, Second s) {
        return new Pair<First, Second>(f, s);
    }
}